1. Field of the Invention
The present invention relates to an in-focus detection method in which an image of the surface of a measuring object is picked up by a video camera while the distance to the measuring object is changed and an in-focus state of the video camera is detected from the fact that the contrast of the image has reached its maximum, as well as a method and an apparatus using the method for non-contact displacement measurement. More particularly, the present invention relates to an in-focus detection method capable of precise in-focus detection and displacement measurement not affected by periodicity, directivity, etc. of a pattern projected on a measuring object, as well as a method and an apparatus using the method for non-contact displacement measurement.
2. Description of the Prior Art
As a non-contact displacement measurement method, in which an image of the surface of a measuring object is picked up by a video camera while the distance to the measuring object is changed and the position of the surface of the measuring object is adapted to be measured according to the position of the video camera when the maximum contrast of the image is attained, that for example disclosed in Japanese Laid-open Patent Publication No. 62-2118 is known.
In this method, a lattice pattern with a predetermined period as shown in FIG. 1 for example is projected on the surface of the measuring object, a frequency component according to the lattice is extracted from an image signal of the surface of the measuring object by applying a filter to the signal, the center of gravity in the vicinity of the peak is taken as the position of the maximum amplitude on the basis of the relationship between the amplitude of the frequency component and the camera distance, and the position of the surface of the measuring object is obtained from the position of the video camera in the position of the maximum-amplitude.
As another method, there is proposed an art in Japanese Laid-open Patent Publication No. 3-261804. In this method, the principle is used that the contrast is higher and the in-focus condition is better the larger the dispersion (variance), from its average value, of the brightness g.sub.x,y of each pixel of the image of the surface of the measuring object is, as shown in FIG. 2. And the point at which the value of the variance is at its maximum is detected so that this point is determined as the in-focus position, and the position of the surface of the measuring object is obtained from the position of the video camera at this time.
However, in the case of the former method disclosed in Japanese Laid-open Patent Publication No. 62-2118, it is required that a lattice pattern with a predetermined period is projected on the surface of the measuring object in a predetermined direction and the periodicity and directivity of the pattern are restricted. Further, the signal component becomes weaker by application thereto of the image signal filter, leading to deterioration in the S/N ratio. Furthermore, since the lattice pattern and the data processing direction are limited to the screen scanning direction, results of the measurement are affected by the surface pattern of the measuring object. Besides, the signal frequency is affected by the condition of the end portions of the image area from which the signal is taken in (the left and right end portions when the pattern is that of vertical stripes) and, hence, such a problem arises that measurement with high precision cannot be achieved.
In the case of the latter method disclosed in Japanese Laid-open Patent Publication No. 3-261804, it sometimes occurs that the change in contrast in the vicinity of the focal point becomes lower, and therefore, there has been a problem that a sufficiently high level of measurement accuracy cannot be attained.